﻿<%@ Control Language="C#" ClassName="BatchLoansList" %>
<script runat="server">
	public int BatchID { set { dsPC.BatchID = value; } }
	double PrincBalance;
	double Reserve;
	double ACQFee;
	double OtherFee;
	double Trackers;
	double ChkToDLR;
	protected override void OnInit(EventArgs e) {
		base.OnInit(e);
		grv.RowCreated += new GridViewRowEventHandler(grv_RowCreated);
	}

	void grv_RowCreated(object sender, GridViewRowEventArgs e) {
		System.Data.DataRowView dv = e.Row.DataItem as System.Data.DataRowView;
		if (e.Row.RowType == DataControlRowType.DataRow) {
			PrincBalance += double.Parse(dv["AmountFinanced"] + "");
			Reserve += double.Parse(dv["Reserve"] + "");
			ACQFee += double.Parse(dv["Fee"] + "");
			OtherFee += double.Parse(dv["TotalDeductFee"] + "");
			Trackers += double.Parse(dv["TrackingDevice"] + "");
			ChkToDLR += double.Parse(dv["CheckToDealer"] + "");
		}
	}
</script>
<style>
TABLE.List {margin-top:10pt}
TABLE.List TD {text-align:right;white-space:nowrap}
TABLE.List TD.Left {text-align:left}
TABLE.List TD.Center {text-align:center}
</style>

<asp:GridView ID="grv" runat="server" BackColor="White" width="100%" CssClass="List"
	BorderColor="#999999" CellPadding="3" ShowFooter="true"
	Font-Size="Small" Font-Names="arial" HeaderStyle-Font-Bold="true" FooterStyle-Font-Bold="true"
	DataSourceID="dsPC" GridLines="Both" AutoGenerateColumns="False" AllowSorting="false" AllowPaging="false">
	<Columns>
		<asp:BoundField DataField="LoanID" HeaderText="Loan #" FooterText="TOTAL" />
		<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-CssClass="Left" />
		<asp:TemplateField HeaderText="Princ Balance">
			<ItemTemplate><%#Eval("AmountFinanced", "{0:c}")%></ItemTemplate>
			<FooterTemplate><%=PrincBalance.ToString("c") %></FooterTemplate>
		</asp:TemplateField>
		<asp:TemplateField HeaderText="Reserve Held">
			<ItemTemplate><%# Eval("Reserve", "{0:c}") %></ItemTemplate>
			<FooterTemplate><%=Reserve.ToString("c")%></FooterTemplate>
		</asp:TemplateField>
		<asp:TemplateField HeaderText="ACQ Fee">
			<ItemTemplate><%# Eval("Fee", "{0:c}") %></ItemTemplate>
			<FooterTemplate><%=ACQFee.ToString("c")%></FooterTemplate>
		</asp:TemplateField>
		<asp:TemplateField HeaderText="Exp Fees">
			<ItemTemplate><%# Eval("TotalDeductFee", "{0:c}") %></ItemTemplate>
			<FooterTemplate><%=OtherFee.ToString("c")%></FooterTemplate>
		</asp:TemplateField>
		<asp:TemplateField HeaderText="Tracking&lt;br&gt;Device">
			<ItemTemplate><%# Eval("TrackingDevice", "{0:c}") %></ItemTemplate>
			<FooterTemplate><%=Trackers.ToString("c")%></FooterTemplate>
		</asp:TemplateField>
		<asp:TemplateField HeaderText="To DRL">
			<ItemTemplate><%# Eval("CheckToDealer", "{0:c}") %></ItemTemplate>
			<FooterTemplate><%=ChkToDLR.ToString("c")%></FooterTemplate>
		</asp:TemplateField>
		<asp:BoundField DataField="AddMosRecourse" HeaderText="Additional<br>Month(s)<br>Recourse" ItemStyle-CssClass="Center" 	HtmlEncode="false" />
	</Columns>
</asp:GridView>

<DS:PurchaseContractsDataSource ID="dsPC" Filter="OK>=0" runat="server" EmtyRowPolicy="None"
		SelectList="LoanID,FirstName+' '+LastName Name, AmountFinanced,Reserve,Fee,TotalDeductFee,TrackerReward TrackingDevice,CheckToDealer,AddMosRecourse">
</DS:PurchaseContractsDataSource>